package activities;
/*
 * JUST A TEST ACTIVITY!
 */
import orm.DBTest;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

import com.example.intellifit.R;

public class TestActivity extends Activity {
	public Button lineGraphBtn, testDBBtn, exerciseStastisticBtn, logFileWriterBtn;
	public Button testSimpleDbBtn;
	public Button statisticsBtn;
	public Button sendToPhpBtn;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test);
		lineGraphBtn = (Button)findViewById(R.id.lineGraphDemoBtn);
		testDBBtn = (Button)findViewById(R.id.testDBBtn);
		testSimpleDbBtn = (Button)findViewById(R.id.simpleDB_test);
		exerciseStastisticBtn = (Button)findViewById(R.id.exerciseStatisticBtn);
		logFileWriterBtn = (Button)findViewById(R.id.logfilewriterBtn);
		
		statisticsBtn = new Button(this);
		statisticsBtn.setText("Open Statistic");
		sendToPhpBtn = new Button(this);
		sendToPhpBtn.setText("Send to PHP");
		sendToPhpBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
//				CommHelper.postDataThread();
//				Toast.makeText(TestActivity.this, "martin", Toast.LENGTH_SHORT).show();
				
//				DatabaseHelper dbh = new DatabaseHelper(TestActivity.this);
//				int rep = dbh.getRepetitionsForExerciseForMonth(1, 2013, 10, 11);
//				Toast.makeText(TestActivity.this, rep + "...", Toast.LENGTH_SHORT).show();
			}
		});
		LinearLayout l = (LinearLayout)findViewById(R.id.TestButtonsID);
		l.addView(statisticsBtn);
		l.addView(sendToPhpBtn);
		statisticsBtn.setOnClickListener(new OnClickListener()
		{

			@Override
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(),StatisticsActivity2.class));				
			}
			
		});
		
		testSimpleDbBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(), SimpleDBTest.class));
				
			}
		});
		
		testDBBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				DBTest dbTest = new DBTest();
				dbTest.runTest(getApplicationContext());
				
			}
		});
		
		exerciseStastisticBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(), ExerciseStatisticActivity.class));
			}
		});
		
		logFileWriterBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(), RepetitionsActivityTest.class));
			}
		});		
				
	}
	
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.test, menu);
		return true;
	}

}
